﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Graphics;

namespace MoveIt.Framework
{
    public enum IDResource
    {
        BALL,
        BODY_LINE_TOP,
        BODY_LINE_LEFT,
        HEAD_LINE_TOP,
        HEAD_LINE_BOTTOM,
        HEAD_LINE_LEFT,
        HEAD_LINE_RIGHT,
    }

    public enum IDTexture
    {
        BLADE,
    }

    public class CResourceManager
    {

        private static CResourceManager m_ResourceManager;
        private CSprite m_Ball;

        private CSprite m_Body_Line_Top;
        private CSprite m_Body_Line_Left;

        private CSprite m_Head_Line_Top;
        private CSprite m_Head_Line_Bottom;
        private CSprite m_Head_Line_Left;
        private CSprite m_Head_Line_Right;

        private Texture2D m_Blade;

        private CResourceManager()
        {
            m_Ball = new CSprite(IDResource.BALL, 9, 40, 40, 9);
            m_Body_Line_Top = new CSprite(IDResource.BODY_LINE_TOP, 9, 10, 20, 9);
            m_Body_Line_Left = new CSprite(IDResource.BODY_LINE_LEFT, 9, 20, 10, 9);
            m_Head_Line_Top = new CSprite(IDResource.HEAD_LINE_TOP, 9, 10, 20, 9);
            m_Head_Line_Bottom = new CSprite(IDResource.HEAD_LINE_BOTTOM, 9, 10, 20, 9);
            m_Head_Line_Left = new CSprite(IDResource.HEAD_LINE_LEFT, 9, 20, 10, 9);
            m_Head_Line_Right = new CSprite(IDResource.HEAD_LINE_RIGHT, 9, 20, 10, 9);
        }

        public static CResourceManager GetInstance()
        {
            if (m_ResourceManager == null)
                m_ResourceManager = new CResourceManager();
            return m_ResourceManager;
        }

        public void Init(ContentManager _ContentManager)
        {
            m_Ball.Init(_ContentManager, @"Image\Object\ball-40-40", 0, 8, 100.0f);
            m_Body_Line_Top.Init(_ContentManager, @"Image\Object\body-TOP", 0, 8, 100.0f);
            m_Body_Line_Left.Init(_ContentManager, @"Image\Object\body-LEFT", 0, 8, 100.0f);
            m_Head_Line_Top.Init(_ContentManager, @"Image\Object\head-TOP", 0, 8, 100.0f);
            m_Head_Line_Bottom.Init(_ContentManager, @"Image\Object\head-BOT", 0, 8, 100.0f);
            m_Head_Line_Left.Init(_ContentManager, @"Image\Object\head-LEFT", 0, 8, 100.0f);
            m_Head_Line_Right.Init(_ContentManager, @"Image\Object\head-RIGHT", 0, 8, 100.0f);
            m_Blade = _ContentManager.Load<Texture2D>(@"Texture\pixel");
        }

        public CSprite GetResource(IDResource _ID)
        {
            switch(_ID)
            {
                case IDResource.BALL:
                    return m_Ball;
                case IDResource.BODY_LINE_LEFT:
                    return m_Body_Line_Left;
                case IDResource.BODY_LINE_TOP:
                    return m_Body_Line_Top;
                case IDResource.HEAD_LINE_TOP:
                    return m_Head_Line_Top;
                case IDResource.HEAD_LINE_BOTTOM:
                    return m_Head_Line_Bottom;
                case IDResource.HEAD_LINE_LEFT:
                    return m_Head_Line_Left;
                case IDResource.HEAD_LINE_RIGHT:
                    return m_Head_Line_Right;
                default:
                    return null;
            }
        }

        public Texture2D GetTexture(IDTexture _ID)
        {
            switch (_ID)
            {
                case IDTexture.BLADE:
                    return m_Blade;
                default:
                    break;
            }

            return null;
        }

        
    }
}
